package controller

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"server_cluster/common/logger"
	"server_cluster/http/model"
)

func (c *Controller) towerRank(ctx *gin.Context) {
	req := new(model.RankReq)
	err := ctx.ShouldBindJSON(req)
	if err != nil {
		logger.Error("parse json error: %v", err)
		ctx.JSON(http.StatusOK, ParamError)
		return
	}
	towerRank, err := c.s.GetTowerRank(uint32(req.Uid))
	if err != nil {
		logger.Error("get tower rank err: %v", err)
		ctx.JSON(http.StatusOK, UnknownError)
		return
	}
	ctx.JSON(http.StatusOK, &model.CommonRsp{Code: 0, Data: towerRank})
}
